﻿using Business.Service;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcAppWeb.Controllers
{
    public class ActionInfoController : BaseDataController
    {
        //
        // GET: /ActionInfo/

        public ActionResult ActionInfo()
        {
            if (Session["UserInfo"] == null) return RedirectToAction("LogOn", "Account");
            else
            {
                AppUserList model = (AppUserList)Session["UserInfo"];
                return View(model);

            }
        }


        ///<summary>
        ///查询日志类型
        ///</summary>
        ///<returns></returns>
        public JsonResult InitJsonResult(string typeName, string startDate, string endDate, string opcontent)
        {
            string where = "  where 1=1 ";
            int page = int.Parse(Request["page"].ToString());
            int rows = int.Parse(Request["rows"].ToString());
            int total = 0;
            if (typeName != "")
            {
                where += " and b.typeName='" + typeName + "'";
            }
            if (opcontent != "")
            {
                where += " and a.opcontent like '%" + opcontent + "%'";
            }
            if (startDate != "" && endDate != "")
            {
                where += " and a.CREATEDATE BETWEEN  to_date('" + startDate + "','yyyy-MM-dd') AND to_date('" + endDate + " 23:59:59 ','yyyy-mm-dd hh24:mi:ss')";
            }
            where += "order by B.TYPECODE,A.CREATEDATE desc";

            var retData = new object();
            BAction db = new BAction();
            retData = db.GetActionInfo(page, rows, out total, where).ToList();
            Dictionary<string, object> json = new Dictionary<string, object>();
            json.Add("total", total);
            json.Add("rows", retData);
            return Json(json);
        }



    }
}
